'''
集合：不可重复元素，无序，无法通过下标进行获取，支持：数字，字符串，布尔，元组
定义：{}，set()
集合循环不能使用while
'''
# 无序的
set1 = {1,2.2,"as",True,(1,1)}
print(set1)
set1 = {"python","java","PHP","C++","python"}
print(set1,type(set1))
# 不支持下标获取元素
# print(set1[1])
# 添加新元素
set1.add("Java")
print(set1)
# 删除某个元素
elemt1 = set1.remove("Java")
print(elemt1)
print(set1)
# 随机删除某个元素
# elemt = set1.pop()
# print(elemt)
# print(set1)
#
print("--------------")
# 差集：set2在set1里面没有的元素
set2 = {"python","java"}
set3 = set1.difference(set2)
print(set1)
print(set2)
print(set3)

# 直接返回set1中set2集合没有的数据
set1.difference_update(set2)
print(set1)
print(set2)

# union 合并
set4 = set1.union(set2)
print(set1)
print(set2)
print(set4)

# for
for elment in set1:
    print(elment)

